1787A - Exponential Equation - CodeForces Solution


constructive algorithms math

Please click on ads to support us..

C++ Code:

#include<bits/stdc++.h>

#define     pb                push_back
#define     all(v)            v.begin(),v.end()
#define     vl                vector<int>
#define     in(a)             for(auto &x : a) cin>>x;
#define     out(a)            for(auto &x : a) cout<<x<<" "
#define     pr(a)             cout<<a<<endl
#define     N                 (int)(1e5 + 10) ///100010
#define     nl                "\n"
#define     mod               1000000007
#define     pr(x)             cout<<x<<"\n"
#define     sz(x)             ((int) x.size())
#define     test              int T; cin>>T; while(T--)
#define     yes               cout<<"Yes"<<endl;
#define     no               cout<<"No"<<endl;
#define     lcm(a,b)           (a*(b/__gcd(a,b)))


typedef long long ll;
typedef long double ld;
typedef long long int lli;
using namespace std;

vector<int> graph[N];
bool visited[N];
ll x;

//binary search using recursion
void bs(int l, int h, int arr[], int n)
{
    if(l<=h)
    {
        int m = (l+h)/2;
        if(n<m) bs(m+1, h, arr, n);
        else if(n>m) bs(l, m-1, arr, n);
        else x = m; ///return Answer
    }

}

//binary search using itterative
void bsi(int l, int h, int arr[], int n)
{
    while(l<=h)
    {
        int mid =(l+h)/2;

    }
}

//Basic DFS
void dfs(int vertex)
{
//    if(visited[vertex]) return;
    visited[vertex] = true;

    for(auto child : graph[vertex])
    {
        if(visited[child]) continue;
        dfs(child);
    }
}

//sieve of Eratohthenes

void prime_generator(int n)
{
    bool prime[n + 1];
    memset(prime, true, sizeof(prime));
    vector<int> veca;

    for (int i=2; i*i<=n; i++)
    {
        if(prime[i]==true)
        {
            veca.push_back(i);
            for(int j=i*i; j<=n; j+=i) prime[j] = false;
        }
    }


    for (int i=0; i<veca.size(); i++) cout<<veca[i]<<endl;
}

void solve()
{
    ll n;
    cin>>n;
    if(n%2) pr(-1);
    else cout<<1<<" "<<(n/2)<<endl;
}

int main()
{
//    ios_base::sync_with_stdio(0);
//    cin.tie(NULL);
    ll t;
    cin>>t;
    while(t--) solve();


}












Comments

Submit
0 Comments
More Questions

628. Maximum Product of Three Numbers
1526A - Mean Inequality
1526B - I Hate 1111
1881. Maximum Value after Insertion
237. Delete Node in a Linked List
27. Remove Element
39. Combination Sum
378. Kth Smallest Element in a Sorted Matrix
162. Find Peak Element
1529A - Eshag Loves Big Arrays
19. Remove Nth Node From End of List
925. Long Pressed Name
1051. Height Checker
695. Max Area of Island
402. Remove K Digits
97. Interleaving String
543. Diameter of Binary Tree
124. Binary Tree Maximum Path Sum
1465. Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts
501A - Contest
160A- Twins
752. Open the Lock
1535A - Fair Playoff
1538F - Interesting Function
1920. Build Array from Permutation
494. Target Sum
797. All Paths From Source to Target
1547B - Alphabetical Strings
1550A - Find The Array
118B - Present from Lena